<#macro saveXmEdit>
<style>
.xmxzEdit-container{
	border-radius: 3px;
    -moz-border-radius: 5px;
    background-clip: padding-box;
    width: 594px;
    height: 449px;
    background: #fff;
    border: 1px solid #eaeaea;
    position: absolute;
    top: 50px;
    left: 30%;
	z-index:1000;
}
.xmxzEdit-container .title {
    border-radius: 3px 3px 0px 0px;
    font-family: 微软雅黑;
    font-weight: 500;
    font-size: 20px;
    color: #fff;
    height: 50px;
    background-color: #1C6DC9;
}
.xmxzEdit-container .title span{
    margin-left: 34px;
    position: absolute;
    top: 15px;
}
.xmxzEdit-container .title .close{
    margin-left: 534px;
    margin-top: -5px;
    cursor: pointer;
}
.xmxzEdit-container  .el-input__inner {
      background-color: #fff;
    background-image: none;
    border: 1px solid #d7e5ea;
    color: #1f2d3d;
    height: 35px;
    float: left;
    padding-left: 10px;
    width: 338px;
    font-size: 15px; 
}
.xmxzEdit-container table td label {
    color: #101010;
    font-size: 15px;
    text-align: right;
    padding-left: 45px;
    padding-right: 24px;
    float: right;
}
.xmxzEdit-container .el-button {
    border: 1px solid #bfcbd9;
    color: #fff;
    background-color: #1C6DC9;
    border-color: #1C6DC9;
    margin-right: 240px;
    cursor: pointer;
    width: 102px;
    height: 40px;
    float: right;
    margin-top: 20px;
    border-radius: 5px;
}
.selectBox {
    background-color: #fff;
    background-image: none;
    border: 1px solid #d9d9d9;
    color: #1f2d3d;
    height: 35px;
    float: left;
    padding-left: 10px;
    width: 260px;
    font-size: 15px;
    border-radius: 5px;
}
</style>
<div id="content_Teacher" style="display: none;">
<form  class="xmxzEdit-container" id="teach_form_1">
    <input name="id" type="hidden" class="el-input__inner"/>
    <input name="matchProArticleId" type="hidden" class="el-input__inner" value="${(matchProArticleItem.id)!}" />
	<h3  class="title">
	 	<span>编辑</span>
	 	<span class="close"><img src="static/cms/www/default/img/sshd/close.png" onclick="addDivShowWindow('content_Teacher','teach_form_1','close','',null)" /></span>
	</h3>
	
	<table style="width: 100%; height: 300px; background-color: fff;">
	  <tr>
	    <td><label style="padding-top: 10px;">姓名:</label></td>
	    <td style="padding-top: 20px;"><input name="techName" maxlength="50" type="text" class="el-input__inner" tip="请输入姓名" required/></td>
	  </tr>
	  <tr>
	    <td class="text_t"><label>性别:</label></td>
	    <td class="text_t">
	    	<select  class="selectBox"  name="techSex">
				<#list sexList as data>
  				<option value ="${data.value!}">${data.name!}</option>
				</#list>  
			</select>
	  </tr>
	   <tr>
	    <td class="text_t"><label>院系:</label></td>
	    <td class="text_t">
	    	<select  class="selectBox"  name="techDept">
			   <#list companyList as data>
  				<option value ="${data.value!}">${data.name!}</option>
				</#list>  
			</select>
	    </td>
	  </tr>
	   <tr>
	    <td class="text_t"><label>职位:</label></td>
	    <td class="text_t"><input type="text" name="techJob" maxlength="300" class="el-input__inner"></td>
	  </tr>
	   <tr>
	    <td class="text_t"><label>邮箱:</label></td>
	    <td class="text_t"><input type="text" name="techEmail" maxlength="100" class="el-input__inner"></td>
	  </tr>
	   <tr>
	    <td class="text_t"><label>联系电话:</label></td>
	    <td class="text_t"><input type="text" name="techTel" maxlength="20" class="el-input__inner"></td>
	  </tr>
	</table>
	<div  class="el-form-item" style="width: 100%;">
		<div class="el-form-item__content" style="margin-left: 0px;">
			<button  type="button" id="btn_select" class="el-button" onclick="addTeamInfo('teacher','teach_form_1')"><span style="font-size: 16px;">确&nbsp;认</span></button>
		</div>
	</div>
</form>
</div>

<div id="content_student" style="display: none;">
<form  class="xmxzEdit-container" id="men_form_1">
	<input name="id" type="hidden" class="el-input__inner"/>
	<input name="matchProArticleId" type="hidden" class="el-input__inner" value="${(matchProArticleItem.id)!}" />
	
	<h3  class="title">
	 	<span>编辑</span>
	 	<span class="close"><img src="static/cms/www/default/img/sshd/close.png" onclick="addDivShowWindow('content_student','men_form_1','close','',null)" /></span>
	</h3>
	
	<table style="width: 100%; height: 300px; background-color: fff;">
	  <tr>
	    <td><label style="padding-top: 10px;">姓名:</label></td>
	    <td style="padding-top: 20px;"><input name="memName" maxlength="50" type="text" class="el-input__inner"  tip="请输入姓名" required/></td>
	  </tr>
	  <tr>
	    <td class="text_t"><label>性别:</label></td>
	    <td class="text_t">
	    	<select  class="selectBox"  name="memSex">
				<#list sexList as data>
  				<option value ="${data.value!}">${data.name!}</option>
				</#list>  
			</select>
	   	</td>
	  </tr>
	   <tr>
	    <td class="text_t"><label>年级:</label></td>
	    <td class="text_t">
	       <select  class="selectBox"  name="memGrade">
			   <#list gradeList as data>
  				<option value ="${data.value!}">${data.name!}</option>
				</#list>  
			</select>
	  </tr>
	   <tr>
	    <td class="text_t"><label>专业:</label></td>
	    <td class="text_t">
	    	<input type="text" name="memMajor" maxlength="20" class="el-input__inner"/>
	    	 <!--<select  class="selectBox"  name="memMajor">
			   <#list maJorList as data>
  				<option value ="${data.value!}">${data.name!}</option>
				</#list>  
			</select>-->
	    </td>
	  </tr>
	   <tr>
	    <td class="text_t"><label>身份证:</label></td>
	    <td class="text_t"><input type="text" name="memId" maxlength="20" class="el-input__inner"></td>
	  </tr>
	   <tr>
	    <td class="text_t"><label>联系电话:</label></td>
	    <td class="text_t"><input type="text" name="memTel" maxlength="20" class="el-input__inner"/></td>
	  </tr>
	</table>
	<div  class="el-form-item" style="width: 100%;">
		<div class="el-form-item__content" style="margin-left: 0px;">
			<button  type="button" id="btn_select" class="el-button" onclick="addTeamInfo('student','men_form_1')"><span style="font-size: 16px;">确&nbsp;认</span></button>
		</div>
	</div>
</form>
</div>

<script type="text/javascript">
var clickObj1 = null;
function addDivShowWindow (divId,formId,state,id,clickObj) {
	LayerShowWindow(divId);
	if(state != "edit") {
		$("#" + formId +" input").each(function(){
		    if(this.name != "matchProArticleId") {
				this.value = "";
		    }
		});	
		$("#" + formId +" select").each(function(){
			$(this).find("option").first().attr("selected", true);
		});	
		
	} else {
	     clickObj1 = clickObj;
	    //老师
		if(formId == "teach_form_1") {
			editDataForm(id,"teacher",clickObj);
		} else {
			editDataForm(id,"men",clickObj);
		}
	}
}

function editDataForm(id,type)
{
	$.ajax({
		type: 'POST',
		url: "matchManager.do?editTeam",
		dataType : 'json',  
		data: {id:id,type:type},
		success: function(data) {
			  if(data.success) {
			     var data = data.obj;
			     if(type == "teacher"){
			     	$("#teach_form_1 input[name='id']").val(data.id);
			     	$("#teach_form_1 input[name='techName']").val(data.techName);
			     	$("#teach_form_1 select[name='techSex']").val(data.techSex);
			     	$("#teach_form_1 select[name='techDept']").val(data.techDept);
			     	$("#teach_form_1 input[name='techJob']").val(data.techJob);
			     	$("#teach_form_1 input[name='techEmail']").val(data.techEmail);
			     	$("#teach_form_1 input[name='techTel']").val(data.techTel);
			     } else {
			     	$("#men_form_1 input[name='id']").val(data.id);
			     	$("#men_form_1 input[name='memName']").val(data.memName);
			     	$("#men_form_1 select[name='memSex']").val(data.memSex);
			     	$("#men_form_1 select[name='memGrade']").val(data.memGrade);
			     	$("#men_form_1 input[name='memMajor']").val(data.memMajor);
			     	$("#men_form_1 input[name='memId']").val(data.memId);
			     	$("#men_form_1 input[name='memTel']").val(data.memTel);
			     }
           	   }
		    },
        error:function(data,textstatus){
          	errorMessage();
          }  
		});
}

function addTeamInfo(type,formId)
{
    var isva = true;
    var tip = "";
	$("#" + formId + " input[required]").each(function(){
		if($(this).val() == "") {
    		tip = $(this).attr("tip");
    		isva = false;
    		return false
		}
  	});
  	if(!isva) {
  		$.alert(tip);
  		return;
  	}
  	if(type != "teacher") {
  		if($("#" + formId + " input[name='memId']").val() != "") {
  			if(!checkCard($("#" + formId + " input[name='memId']").val()))
  			{
  				$.alert("不合法身份证！");
  				return;
  			}
  		}
  	}
	var url = "";
    if(type == "teacher") {
    	url = "matchManager.do?teacher";
    } else {
		url = "matchManager.do?member";    
    }
	$.ajax({
		type: 'POST',
		url: url,
		dataType : 'json',  
		data: $("#" + formId).serialize(),
		success: function(data) {
			  if(data.success) {
			     $.alert(data.msg);
         			//team_grid  teacher_grid
         			var obj = data.obj;
         			if (clickObj1 != null) {
         				delTr(clickObj1);
         				clickObj1 = null;
         			}
					if(type == "teacher") {
					    var html = "<tr id='teacher_"+obj.id+"'> <td name='xmId' style='display:none'><input type='checkbox' value='"+obj.id+"'></input></td>" +
					    " <td>"+obj.techName+"</td> "+
					    "<td>"+getOptionText("techSex",obj.techSex)+"</td> "+
					    "<td>"+getOptionText("techDept",obj.techDept)+"</td> "+
					    "<td>"+obj.techJob+"</td> " + 
					    "<td>"+obj.techEmail+"</td> "+
					    "<td>"+obj.techTel+"</td> "+
					    "<td> "+
					     "<a onclick=\"addDivShowWindow('content_Teacher','teach_form_1','edit',"+obj.id+",this)\">[编辑]</a> "+
					     "<a onclick=\"delTeacherOrMember("+obj.id+",this,'teacher')\">[删除]</a> "+
					     "</td> </tr>";
						addTableG("teacher_grid",html);
		         		addDivShowWindow('content_Teacher','teach_form_1','close','');
					} else {
					 var html = "<tr id='team_"+obj.id+"'> <td name='xmId' style='display:none'><input type='checkbox' value='"+obj.id+"'></input></td>" +
					    " <td>"+obj.memName+"</td> "+
					    "<td>"+getOptionText("memSex",obj.memSex)+"</td> "+
					    "<td>"+obj.memGrade+"</td> "+
					    "<td>"+obj.memMajor+"</td> " + 
					    "<td>"+obj.memId+"</td> "+
					    "<td>"+obj.memTel+"</td> "+
					    "<td> "+
					     "<a onclick=\"addDivShowWindow('content_student','men_form_1','edit',"+obj.id+",this)\">[编辑]</a> "+
					     "<a onclick=\"delTeacherOrMember("+obj.id+",this,'member')\">[删除]</a> "+
					     "</td> </tr>";
						addTableG("team_grid",html);
						addDivShowWindow('content_student','men_form_1','close','');
					}
		         
           	   } else {
           	   	 $.alert(data.msg);
           	   }
		 },
        error:function(data,textstatus){
          	errorMessage();
          }  
	});
}

function getOptionText(selectName,value) {
	var txt = "";
	$("select[name="+selectName+"] option").each(function(){
        if($(this).val() == value){
        	txt = $(this).html();
        	return txt;
       }
    });
	return txt;	
}

</script>

</#macro>